package com.term.util.string;

import java.util.function.Function;

/**
 * Created by chenGang on 2017/1/11.
 */
public class StringUtils {
    /**
     * 首字符大写
     *
     * @param str
     * @return
     */
    public static String toFirstUpCase(String str) {
        return toSomeCase(str, String::toUpperCase);
    }

    /**
     * 首字符小写
     *
     * @param str
     * @return
     */
    public static String toFirstLowerCase(String str) {
        return toSomeCase(str, String::toLowerCase);
    }

    private static String toSomeCase(String str, Function<String, String> fun) {
        return fun.apply(str.substring(0, 1)) + str.substring(1, str.length());
    }
}
